﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class StageConfig_Dev_M : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected override bool CheckPermission()
    {
        return Permission.GetManagerPermission();
    }

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (lb_RelationList.SelectedItem == null || lb_NoHaveBeRelationList.SelectedItem==null)
        {
            return;
        }
        string leftId = lb_RelationList.SelectedItem.Value;
        string rightId = lb_NoHaveBeRelationList.SelectedItem.Value;

        PKURG.CostSplit.Business.Relation.Relate(leftId, rightId, "hanmeimei", 4);
        Refresh();
    }
    protected void btnDel_Click(object sender, EventArgs e)
    {
        if (lb_RelationList.SelectedItem == null || lb_HaveBeRelationList.SelectedItem == null)
        {
            return;
        }
        string leftId = lb_RelationList.SelectedItem.Value;
        string rightId = lb_HaveBeRelationList.SelectedItem.Value;

        PKURG.CostSplit.Business.Relation.UnRelate(leftId, rightId, 4);
        Refresh();
    }
    protected void lb_RelationList_SelectedIndexChanged(object sender, EventArgs e)
    {
        Refresh();
    }

    private void Refresh()
    {
        lb_HaveBeRelationList.DataBind();
        lb_NoHaveBeRelationList.DataBind();
    }
    protected void ddlProjectList_SelectedIndexChanged(object sender, EventArgs e)
    {
        lb_RelationList.DataBind();
        if (lb_RelationList.Items.Count>0)
        {
            lb_RelationList.SelectedIndex = 0;
        }
        Refresh();
    }
}